import { MenuItem } from '@/types/dashboard/fastmenu/index';
// 递归提取所有 is_pick = true 的 id
export const extractIds = (
  data: MenuItem[],
  key = 'is_pick',
  value = true
): number[] => {
  let ids: number[] = [];
  data.forEach((item: any) => {
    if (item[key] === value) {
      ids.push(item.id);
    }
    if (item.children) {
      ids = ids.concat(extractIds(item.children, key, value));
    }
  });
  return ids;
};
